package zuoye29.zuoye5;

import java.io.UnsupportedEncodingException;

public class zifu {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str = "你好，世界！";
        int byteCount = str.getBytes("UTF-8").length; // 获取字符串的字节数
        System.out.println("字符串字节数：" + byteCount);

        int charCount = str.length(); // 获取字符串的字符数
        System.out.println("字符串字符数：" + charCount);
    }
}
